// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The cwkshell Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_VIEWS_SHELL_CONTENT_CLIENT_SHELL_CONTENT_BROWSER_CLIENT_H_
#define UI_VIEWS_SHELL_CONTENT_CLIENT_SHELL_CONTENT_BROWSER_CLIENT_H_
#pragma  once
#include <string>

#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/platform_file.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"

namespace cuc {
	namespace shell {
		class ShellBrowserContext;
		class ShellBrowserMainParts;
		class ShellResourceDispatcherHostDelegate;

		class ShellContentBrowserClient : public content::ContentBrowserClient,
			public content::NotificationObserver {
		public:
			// Gets the current instance.
			static ShellContentBrowserClient* Get();

			ShellContentBrowserClient();
			virtual ~ShellContentBrowserClient();

			// ContentBrowserClient overrides.
			virtual content::BrowserMainParts* CreateBrowserMainParts(
				const content::MainFunctionParams& parameters) OVERRIDE;
			virtual void RenderProcessHostCreated(content::RenderProcessHost* host) OVERRIDE;
			virtual net::URLRequestContextGetter* CreateRequestContext(
				content::BrowserContext* browser_context,
				content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
			virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
				content::BrowserContext* browser_context,
				const base::FilePath& partition_path,
				bool in_memory,
				content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
			virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
				int child_process_id) OVERRIDE;
			virtual void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
				const GURL& url,
				webkit_glue::WebPreferences* prefs) OVERRIDE;
			virtual void ResourceDispatcherHostCreated() OVERRIDE;
			virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
			virtual std::string GetDefaultDownloadName() OVERRIDE;
			virtual bool SupportsBrowserPlugin(content::BrowserContext* browser_context,
				const GURL& url) OVERRIDE;
			virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
				content::WebContents* web_contents) OVERRIDE;
			virtual content::QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
		

			// NotificationObserver implementation.
			virtual void Observe(int type,
				const content::NotificationSource& source,
				const content::NotificationDetails& details) OVERRIDE;

			ShellBrowserContext* browser_context();
			ShellBrowserContext* off_the_record_browser_context();
			ShellResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() {
				return resource_dispatcher_host_delegate_.get();
			}
			ShellBrowserMainParts* shell_browser_main_parts() {
				return shell_browser_main_parts_;
			}

		private:
			ShellBrowserContext* ShellBrowserContextForBrowserContext(
				content::BrowserContext* content_browser_context);

			scoped_ptr<ShellResourceDispatcherHostDelegate>
				resource_dispatcher_host_delegate_;

			base::FilePath webkit_source_dir_;

			base::PlatformFile hyphen_dictionary_file_;

			ShellBrowserMainParts* shell_browser_main_parts_;

			content::NotificationRegistrar registrar_;
		};
	}  // namespace shell
}  // namespace cuc

#endif  // UI_VIEWS_SHELL_CONTENT_CLIENT_SHELL_CONTENT_BROWSER_CLIENT_H_
